package com.itheima.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * @Author：TomHoll
 * @Version: 1.1 2022/7/11 8:53
 */
@Configuration
public class RedisConfig {

    @Bean
    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
    	RedisTemplate<Object, Object> template = new RedisTemplate();
    	template.setConnectionFactory(redisConnectionFactory);
    	//设置key的序列化方式为String
    	template.setKeySerializer(new StringRedisSerializer());
    	return template;
    }
}
